#!/usr/bin/env python
#coding:utf-8

import wx
import SheetPanel
import MyGauge

class MainView ( wx.Panel ):
    
    def __init__( self, parent ):
        wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.TAB_TRAVERSAL )
        
        bSizer1 = wx.BoxSizer( wx.VERTICAL )
        
        bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_bitmap1 = wx.StaticBitmap( self, wx.ID_ANY, wx.Bitmap( u"images/leaf.png", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer2.Add( self.m_bitmap1, 0, wx.ALL, 5 )
        
        self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"在这里查看实时数据以及测量结果", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText1.Wrap( -1 )
        self.m_staticText1.SetFont( wx.Font( 15, 70, 90, 92, False, wx.EmptyString ) )
        self.m_staticText1.SetForegroundColour( wx.Colour( 32, 141, 20 ) )
        
        bSizer2.Add( self.m_staticText1, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        bSizer1.Add( bSizer2, 0, wx.EXPAND, 5 )
        
        self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
        bSizer1.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
        
        self.sheetpanel = SheetPanel.SheetPanel(self)
        
        bSizer1.Add((0,0), 1, wx.ALL, 5)
        bSizer1.Add(self.sheetpanel, 0, wx.ALL | wx.ALIGN_CENTER, 5)
        bSizer1.Add((0,0), 1, wx.ALL, 5)
        
        self.SetSizer( bSizer1 )
        self.Layout()
        
        self.con = None
        
    def SetController(self, con):
        self.con = con
        
    def GetController(self):
        return self.con
    
    def DetachController(self):
        self.con.DetachMainView()
        
    def SetRealPV(self, pv1, pv2, pv3, pv4, pv5, pv6):
        self.SetLeftRealPV(pv1, pv2, pv3)
        self.SetRightRealPV(pv4, pv5, pv6)
        
    def SetDistance(self, lh, lv, rh, rv):
        self.sheetpanel.SetDistance(lh, lv, rh, rv)
    
    def SetLeftRealPV(self, pv1, pv2, pv3):
        #print pv1, pv2, pv3
        self.sheetpanel.SetLeftRealPV(pv1, pv2, pv3)
        
    def SetRightRealPV(self, pv4, pv5, pv6):
        #print pv4, pv5, pv6
        self.sheetpanel.SetRightRealPV(pv4, pv5, pv6)
        
    def SetLeftZeroPV(self, pv1, pv2, pv3):
        self.sheetpanel.SetLeftZeroPV(pv1, pv2, pv3)
    
    def SetRightZeroPV(self, pv4, pv5, pv6):
        self.sheetpanel.SetRightZeroPV(pv4, pv5, pv6)
        
    def SetLeftPartPV(self, pv1, pv2, pv3):
        self.sheetpanel.SetLeftPartPV(pv1, pv2, pv3)
    
    def SetRightPartPV(self, pv4, pv5, pv6):
        self.sheetpanel.SetRightPartPV(pv4, pv5, pv6)
        
    def SetLeftConsTolerInfo(self, angle, toler):
        self.sheetpanel.SetLeftConsTolerInfo(angle, toler)
    
    def SetLeftCambTolerInfo(self, angle, toler):
        self.sheetpanel.SetLeftCambTolerInfo(angle, toler)
    
    def SetRightConsTolerInfo(self, angle, toler):
        self.sheetpanel.SetRightConsTolerInfo(angle, toler)   
        
    def SetRightCambTolerInfo(self, angle, toler):
        self.sheetpanel.SetRightCambTolerInfo(angle, toler)
        
    def SetLeftResult(self, consangle, consresult, cambangle, cambresult):
        self.sheetpanel.SetLeftResult(consangle, consresult, cambangle, cambresult)
        
    def SetRightResult(self, consangle, consresult, cambangle, cambresult):
        self.sheetpanel.SetRightResult(consangle, consresult, cambangle, cambresult)
        
    def SetLenResult(self, len, len_result, lendiff, len_diff_result):
        self.sheetpanel.SetLenResult(len, len_result, lendiff, len_diff_result)
        
        
#MyGauge.MyGauge(self, size = (-1, 70))

class ResultView ( wx.Panel ):
    
    def __init__( self, parent ):
        wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.TAB_TRAVERSAL )
        
        bSizer1 = wx.BoxSizer( wx.VERTICAL )
        
        bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_bitmap1 = wx.StaticBitmap( self, wx.ID_ANY, wx.Bitmap( u"images/leaf.png", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer2.Add( self.m_bitmap1, 0, wx.ALL, 5 )
        
        self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"在这里查看醒目测量结果", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText1.Wrap( -1 )
        self.m_staticText1.SetFont( wx.Font( 15, 70, 90, 92, False, wx.EmptyString ) )
        self.m_staticText1.SetForegroundColour( wx.Colour( 32, 141, 20 ) )
        
        bSizer2.Add( self.m_staticText1, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        
        bSizer1.Add( bSizer2, 0, wx.EXPAND, 5 )
        
        self.m_staticline1 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
        bSizer1.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
        
        bSizer45 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_staticText38 = wx.StaticText( self, wx.ID_ANY, u"条码", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText38.Wrap( -1 )
        self.m_staticText38.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        
        bSizer45.Add( self.m_staticText38, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcBarcode = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( -1,30 ), wx.TE_READONLY )
        self.m_tcBarcode.SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), 70, 90, 92, False, wx.EmptyString ) )
        
        bSizer45.Add( self.m_tcBarcode, 1, wx.ALL|wx.EXPAND, 5 )
        
        
        bSizer1.Add( bSizer45, 0, wx.EXPAND, 5 )
        
        bSizer46 = wx.BoxSizer( wx.HORIZONTAL )
        
        sbSizer6 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"左" ), wx.VERTICAL )
        
        bSizer47 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_staticText51 = wx.StaticText( self, wx.ID_ANY, u"左前束角", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText51.Wrap( -1 )
        self.m_staticText51.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        self.m_staticText51.SetForegroundColour( wx.Colour( 0, 0, 0 ) )
        
        bSizer47.Add( self.m_staticText51, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcLConsAngle = wx.TextCtrl( self, wx.ID_ANY, u"0.000", wx.DefaultPosition, wx.Size( 120,-1 ), wx.TE_READONLY|wx.TE_RIGHT )
        self.m_tcLConsAngle.SetMaxLength( 0 ) 
        self.m_tcLConsAngle.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        self.m_tcLConsAngle.SetForegroundColour( wx.Colour( 0, 0, 0 ) )
        self.m_tcLConsAngle.SetBackgroundColour( wx.Colour( 255, 128, 0 ) )
        
        bSizer47.Add( self.m_tcLConsAngle, 1, wx.ALL|wx.EXPAND, 5 )
        
        self.m_stLStdConsAngle = wx.StaticText( self, wx.ID_ANY, u"90.000", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_stLStdConsAngle.Wrap( -1 )
        self.m_stLStdConsAngle.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer47.Add( self.m_stLStdConsAngle, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        self.m_staticText521 = wx.StaticText( self, wx.ID_ANY, u"~", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText521.Wrap( -1 )
        self.m_staticText521.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer47.Add( self.m_staticText521, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        self.m_stLConsToler = wx.StaticText( self, wx.ID_ANY, u"5.000", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_stLConsToler.Wrap( -1 )
        self.m_stLConsToler.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer47.Add( self.m_stLConsToler, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        
        sbSizer6.Add( bSizer47, 0, wx.EXPAND, 5 )
        #############################################################################################
        self.m_mgLConsAngle = MyGauge.MyGauge(self)#, size = (-1, 70))
        #self.m_mgLConsAngle.SetValue(2.6)
        #self.m_mgLConsAngle.SetMinValue(1.5)
        #self.m_mgLConsAngle.SetMaxValue(4.5)
        sbSizer6.Add( self.m_mgLConsAngle, 1, wx.ALL|wx.EXPAND, 5 )
        
        bSizer48 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_staticText511 = wx.StaticText( self, wx.ID_ANY, u"左外倾角", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText511.Wrap( -1 )
        self.m_staticText511.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        self.m_staticText511.SetForegroundColour( wx.Colour( 0, 0, 0 ) )
        
        bSizer48.Add( self.m_staticText511, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcLCambAngle = wx.TextCtrl( self, wx.ID_ANY, u"0.000", wx.DefaultPosition, wx.Size( 120,-1 ), wx.TE_READONLY|wx.TE_RIGHT )
        self.m_tcLCambAngle.SetMaxLength( 0 ) 
        self.m_tcLCambAngle.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        self.m_tcLCambAngle.SetForegroundColour( wx.Colour( 0, 0, 0 ) )
        self.m_tcLCambAngle.SetBackgroundColour( wx.Colour( 255, 128, 0 ) )
        
        bSizer48.Add( self.m_tcLCambAngle, 1, wx.ALL|wx.EXPAND, 5 )
        
        self.m_stLStdCambAngle = wx.StaticText( self, wx.ID_ANY, u"90.000", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_stLStdCambAngle.Wrap( -1 )
        self.m_stLStdCambAngle.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer48.Add( self.m_stLStdCambAngle, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        self.m_staticText5212 = wx.StaticText( self, wx.ID_ANY, u"~", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText5212.Wrap( -1 )
        self.m_staticText5212.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer48.Add( self.m_staticText5212, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        self.m_stLCambToler = wx.StaticText( self, wx.ID_ANY, u"5.000", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_stLCambToler.Wrap( -1 )
        self.m_stLCambToler.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer48.Add( self.m_stLCambToler, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        
        sbSizer6.Add( bSizer48, 0, wx.EXPAND, 5 )
        
        self.m_mgLCambAngle = MyGauge.MyGauge(self, size = (-1, 70))
        sbSizer6.Add( self.m_mgLCambAngle, 1, wx.ALL|wx.EXPAND, 5 )
        
        
        bSizer46.Add( sbSizer6, 1, wx.EXPAND|wx.ALL, 5 )
        
        self.m_staticline18 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL )
        bSizer46.Add( self.m_staticline18, 0, wx.EXPAND |wx.ALL, 5 )
        
        sbSizer8 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, u"右" ), wx.VERTICAL )
        
        bSizer49 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_staticText512 = wx.StaticText( self, wx.ID_ANY, u"右前束角", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText512.Wrap( -1 )
        self.m_staticText512.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        self.m_staticText512.SetForegroundColour( wx.Colour( 0, 0, 0 ) )
        
        bSizer49.Add( self.m_staticText512, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcRConsAngle = wx.TextCtrl( self, wx.ID_ANY, u"0.000", wx.DefaultPosition, wx.Size( 120,-1 ), wx.TE_READONLY|wx.TE_RIGHT )
        self.m_tcRConsAngle.SetMaxLength( 0 ) 
        self.m_tcRConsAngle.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        self.m_tcRConsAngle.SetForegroundColour( wx.Colour( 0, 0, 0 ) )
        self.m_tcRConsAngle.SetBackgroundColour( wx.Colour( 255, 128, 0 ) )
        
        bSizer49.Add( self.m_tcRConsAngle, 1, wx.ALL|wx.EXPAND, 5 )
        
        self.m_stRStdConsAngle = wx.StaticText( self, wx.ID_ANY, u"90.000", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_stRStdConsAngle.Wrap( -1 )
        self.m_stRStdConsAngle.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer49.Add( self.m_stRStdConsAngle, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        self.m_staticText5213 = wx.StaticText( self, wx.ID_ANY, u"~", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText5213.Wrap( -1 )
        self.m_staticText5213.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer49.Add( self.m_staticText5213, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        self.m_stRConsToler = wx.StaticText( self, wx.ID_ANY, u"5.000", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_stRConsToler.Wrap( -1 )
        self.m_stRConsToler.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer49.Add( self.m_stRConsToler, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        
        sbSizer8.Add( bSizer49, 0, wx.EXPAND, 5 )
        
        self.m_mgRConsAngle = MyGauge.MyGauge(self, size = (-1, 70))
        sbSizer8.Add( self.m_mgRConsAngle, 1, wx.ALL|wx.EXPAND, 5 )
        
        bSizer50 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_staticText5111 = wx.StaticText( self, wx.ID_ANY, u"右外倾角", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText5111.Wrap( -1 )
        self.m_staticText5111.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        self.m_staticText5111.SetForegroundColour( wx.Colour( 0, 0, 0 ) )
        
        bSizer50.Add( self.m_staticText5111, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
        
        self.m_tcRCambAngle = wx.TextCtrl( self, wx.ID_ANY, u"0.000", wx.DefaultPosition, wx.Size( 120,-1 ), wx.TE_READONLY|wx.TE_RIGHT )
        self.m_tcRCambAngle.SetMaxLength( 0 ) 
        self.m_tcRCambAngle.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        self.m_tcRCambAngle.SetForegroundColour( wx.Colour( 0, 0, 0 ) )
        self.m_tcRCambAngle.SetBackgroundColour( wx.Colour( 255, 128, 0 ) )
        
        bSizer50.Add( self.m_tcRCambAngle, 1, wx.ALL|wx.EXPAND, 5 )
        
        self.m_stRStdCambAngle = wx.StaticText( self, wx.ID_ANY, u"90.000", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_stRStdCambAngle.Wrap( -1 )
        self.m_stRStdCambAngle.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer50.Add( self.m_stRStdCambAngle, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        self.m_staticText52121 = wx.StaticText( self, wx.ID_ANY, u"~", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText52121.Wrap( -1 )
        self.m_staticText52121.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer50.Add( self.m_staticText52121, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        self.m_stRCambToler = wx.StaticText( self, wx.ID_ANY, u"5.000", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_stRCambToler.Wrap( -1 )
        self.m_stRCambToler.SetFont( wx.Font( 14, 70, 90, 90, False, wx.EmptyString ) )
        
        bSizer50.Add( self.m_stRCambToler, 0, wx.ALL|wx.ALIGN_BOTTOM, 5 )
        
        
        sbSizer8.Add( bSizer50, 0, wx.EXPAND, 5 )
        
        self.m_mgRCambAngle = MyGauge.MyGauge(self, size = (-1, 70))
        sbSizer8.Add( self.m_mgRCambAngle, 1, wx.ALL|wx.EXPAND, 5 )
        
        
        bSizer46.Add( sbSizer8, 1, wx.EXPAND|wx.ALL, 5 )
        
        
        bSizer1.Add( bSizer46, 1, wx.EXPAND, 5 )
        
        bSizer51 = wx.BoxSizer( wx.HORIZONTAL )
        
        self.m_staticText381 = wx.StaticText( self, wx.ID_ANY, u"扭矩", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText381.Wrap( -1 )
        self.m_staticText381.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        
        bSizer51.Add( self.m_staticText381, 0, wx.ALL, 5 )
        
        self.m_tcTorque = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer51.Add( self.m_tcTorque, 0, wx.ALL|wx.EXPAND, 5 )
        
        self.m_staticText382 = wx.StaticText( self, wx.ID_ANY, u"角度", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText382.Wrap( -1 )
        self.m_staticText382.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        
        bSizer51.Add( self.m_staticText382, 0, wx.ALL, 5 )
        
        self.m_tcAngle = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer51.Add( self.m_tcAngle, 0, wx.ALL|wx.EXPAND, 5 )
        
        self.m_staticText383 = wx.StaticText( self, wx.ID_ANY, u"结果", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.m_staticText383.Wrap( -1 )
        self.m_staticText383.SetFont( wx.Font( 18, 70, 90, 92, False, wx.EmptyString ) )
        
        bSizer51.Add( self.m_staticText383, 0, wx.ALL, 5 )
        
        self.m_tcFocResult = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer51.Add( self.m_tcFocResult, 0, wx.ALL|wx.EXPAND, 5 )
        
        
        bSizer1.Add( bSizer51, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 )
        
        
        self.SetSizer( bSizer1 )
        self.Layout()
        bSizer1.Fit( self )
        
        self.con = None
        
    def SetController(self, con):
        self.con = con
        
    def GetController(self):
        return self.con
    
    def DetachController(self):
        self.con.DetachResultView()
        
    def SetLeftConsTolerInfo(self, angle, toler):
        if not angle and not toler:
            self.m_stLStdConsAngle.SetLabel(u'-----')
            self.m_stLConsToler.SetLabel('-----')
            self.m_mgLConsAngle.SetMinValue(-100)
            self.m_mgLConsAngle.SetMaxValue(100)
            self.m_mgLConsAngle.SetRange((-200,200))
        else:
            self.m_stLStdConsAngle.SetLabel(u'%.3f' % angle)
            self.m_stLConsToler.SetLabel('%.3f' % toler)
            self.m_mgLConsAngle.SetMinValue(angle)
            self.m_mgLConsAngle.SetMaxValue(toler)
            self.m_mgLConsAngle.SetRange((angle - 0.05, toler + 0.05))
    
    def SetLeftCambTolerInfo(self, angle, toler):
        if not angle and not toler:
            self.m_stLStdCambAngle.SetLabel(u'-----')
            self.m_stLCambToler.SetLabel('-----')
            #self.m_mgLCambAngle.SetMinValue(-100)
            #self.m_mgLCambAngle.SetMaxValue(100)
            #self.m_mgLCambAngle.SetRange((-200,200))
            self.m_mgLCambAngle.SetMinValue(-100)
            self.m_mgLCambAngle.SetMaxValue(100)
            self.m_mgLCambAngle.SetRange((-200,200))
        else:
            self.m_stLStdCambAngle.SetLabel(u'%.3f' % angle)
            self.m_stLCambToler.SetLabel('%.3f' % toler)
            self.m_mgLCambAngle.SetMinValue(angle)
            self.m_mgLCambAngle.SetMaxValue(toler)
            self.m_mgLCambAngle.SetRange((angle - 0.05, toler + 0.05))
    
    def SetRightConsTolerInfo(self, angle, toler):
        if not angle and not toler:
            self.m_stRStdConsAngle.SetLabel(u'-----')
            self.m_stRConsToler.SetLabel('-----')
            self.m_mgRConsAngle.SetMinValue(-100)
            self.m_mgRConsAngle.SetMaxValue(100)
            self.m_mgRConsAngle.SetRange((-200,200))
        else:
            self.m_stRStdConsAngle.SetLabel(u'%.3f' % angle)
            self.m_stRConsToler.SetLabel('%.3f' % toler) 
            self.m_mgRConsAngle.SetMinValue(angle)
            self.m_mgRConsAngle.SetMaxValue(toler)
            self.m_mgRConsAngle.SetRange((angle - 0.05, toler + 0.05))
        
    def SetRightCambTolerInfo(self, angle, toler):
        if not angle and not toler:
            self.m_stRStdCambAngle.SetLabel(u'-----')
            self.m_stRCambToler.SetLabel('-----')
            self.m_mgRCambAngle.SetMinValue(-100)
            self.m_mgRCambAngle.SetMaxValue(100)
            self.m_mgRCambAngle.SetRange((-200,200))
        else:
            self.m_stRStdCambAngle.SetLabel(u'%.3f' % angle)
            self.m_stRCambToler.SetLabel('%.3f' % toler)
            self.m_mgRCambAngle.SetMinValue(angle)
            self.m_mgRCambAngle.SetMaxValue(toler)
            self.m_mgRCambAngle.SetRange((angle - 0.05, toler + 0.05))
        
    def SetRightResult(self, consangle, consresult, cambangle, cambresult):
        self.m_tcRCambAngle.SetLabel('%.3f' % cambangle)
        if cambresult:
            self.m_tcRCambAngle.SetForegroundColour(wx.GREEN)
        else:
            self.m_tcRCambAngle.SetForegroundColour(wx.RED)
        self.m_mgRCambAngle.SetValue(cambangle)
        
        self.m_tcRConsAngle.SetLabel('%.3f' % consangle)
        if consresult:
            self.m_tcRConsAngle.SetForegroundColour(wx.GREEN)
        else:
            self.m_tcRConsAngle.SetForegroundColour(wx.RED)
        self.m_mgRConsAngle.SetValue(consangle)
            
    def SetLeftResult(self, consangle, consresult, cambangle, cambresult):
        self.m_tcLCambAngle.SetLabel('%.3f' % cambangle)
        if cambresult:
            self.m_tcLCambAngle.SetForegroundColour(wx.GREEN)
        else:
            self.m_tcLCambAngle.SetForegroundColour(wx.RED)
        self.m_mgLCambAngle.SetValue(cambangle)
        
        self.m_tcLConsAngle.SetLabel('%.3f' % consangle)
        if consresult:
            self.m_tcLConsAngle.SetForegroundColour(wx.GREEN)
        else:
            self.m_tcLConsAngle.SetForegroundColour(wx.RED)
        self.m_mgLConsAngle.SetValue(consangle)
            
    def SetFocResult(self, t, a, ok):
        self.m_tcFocResult.SetForegroundColour(ok == 'OK' and wx.GREEN or wx.RED)
        self.m_tcFocResult.SetValue(ok)
        
        self.m_tcAngle.SetValue(u'%.3f' % a)
        self.m_tcTorque.SetValue(u'%.3f' % t)
            
    def SetBarcode(self, barcode, ok):
        self.m_tcBarcode.SetForegroundColour(ok and wx.BLACK or wx.RED)
        self.m_tcBarcode.SetValue(barcode)
        
        